Skip to content

One more Map::Units function at 100%: UpdateSiegeTent - #473

Merged
gynt merged 4 commits into
sourcehold:mainfrom
kotijekriv:reimpl/units-D-siegetent-100
Nov 24, 2026
Merged

gynt merged 4 commits into
sourcehold:mainfrom
kotijekriv:reimpl/units-D-siegetent-100

Conversation

@kotijekriv

Copy link
Copy Markdown
Contributor

One more function at 100%, with no header changes. Units::UpdateSiegeTent is from gynt's units branch
reimpl/map-units-updatefunctions (his draft #204; his #286, merged into that branch as c933f79, took this
file's body from reimpl/Wilps-2026-10-18), and the commit credits him as co-author.

Function Address Before After
Units::UpdateSiegeTent 0x005307B0 gynt's draft 69.44% (8d684a9) 100.0%, under /GL

What got it to 100%. One store moved and one written twice:

  • The ULS_TRANSITIONING store stands in front of the fixedRng & 2 test, as in the original (0x005307FA). The
    draft wrote it in both arms, so the merged store landed behind the test.
  • With one store in front of the if, MSVC turns the type into a branch-free select (sbb): so the state_2 store
    (US_FIRE_WEAPONUnk) is written in both arms behind the type store. The compiler merges the two copies into one
    store behind the join (0x0053082C) and keeps the original's branches (0x0053080B / 0x00530816).
  • The frame >= 4 test after & 3 can never be true, but the original compares and stores it (0x005307D1): it
    stays, with a fixme: comment.
  • Names: buildingEntryInfos[BEIE_KEEP] for the keep's entry (y is read before x, hence the two locals).
    field_0x3bc has no better name in this tree; in gynt's catapult, ballista and fire-ballista drafts it is set to
    -40 .. -200 and counted up before firing, so it is probably the siege engines' reload cooldown (reset here so a
    new engine can fire at once).

Measured.

  • Setup: the bundled MSVC1400-SP1 against the Steam Stronghold Crusader.exe (3bb0a8c1…5387ac5a), both resolver
    sets enabled locally (not committed), and sourcehold's reccmp with --resolve-wrapped-calls --ignore-security-cookie.
  • Full build: an all-on build of this commit on main 0e4a83b, with both resolver sets on and the branch's own /GL list (main's plus the one line this commit adds), and with 0x004314E0 (the MapEditorLandscaping_GeneralButtons handler) left out and its resolver off, as in main's baseline: 0 failed of 2,426 compile steps, 99.58 over 2,442 functions. UpdateSiegeTent reads 100.0 raw and normalised there too, with no diff entry. No main function reads differently: against main's own build (made at f489b72, 2,439 functions) the only other changes are main's since then, One more UI::MenuModals function at 100%: ProgressBarBox #467's MenuModalRenderFunction_ProgressBarBox and UI: the single-player game launch at 100% #466's LaunchSinglePlayerGameUnk at 100.0 and Constructor_MenuModal_ProgressBarBox at 100.0 (93.8 before One more UI::MenuModals function at 100%: ProgressBarBox #467); every other function reads exactly what it read before (unrounded 99.5790 raw and 99.5529 normalised, 2,326 functions at 100.0 raw; main 0e4a83b alone: 99.5788 and 99.5528 over 2,441, 2,325 at 100.0).
  • Our own narrower run: real builds of our units stack's head (Reimplement 47 UnitsState functions at 100% and restyle 28 more #378 and the units on it; every header this file
    includes is the same there as on main 0e4a83b, and its one callee, calculatePreferredRelativeOrientation,
    is reimplemented in neither). With this file and its /GL line: UpdateSiegeTent 100.0% raw and normalised, no
    diff entries, 345 functions, none of the other 344 reading differently from the build without it.
  • Not run in game.

Checks: openshc-pr-check gives 0 ERROR and 1 CHECK: field_0x3bc is a placeholder name (see above).

Other PRs

🤖 Generated with Claude Code

Units::UpdateSiegeTent, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his draft PR 204; the
file's commits there: 609ef6d, the 69.44% import, then his 2fe31a8, 8d684a9 at 69.44%, 974c32f's
clang-format, and c933f79, his PR 286 merged into that branch, which took this file's body from
reimpl/Wilps-2026-10-18). It reads a true 100.0 / 100.0. The statements are his; what the text needed is where
two of them stand.

1. The ULS_TRANSITIONING store stands in front of the `fixedRng & 2` test, as in the original (0x005307FA, the
   test at 0x00530803). The draft wrote it in both arms so that the type stays a branch, and the compiler then
   placed the merged store behind the test. Written once in front of the if, the type becomes a branch-free select
   (sbb) unless the arms hold more than the one store: so the state_2 store, behind the keep reads in the draft,
   is written in both arms behind the type store. The compiler merges the two copies into the one store behind
   the join (0x0053082C) and keeps the branches (0x0053080B / 0x00530816).
2. The names of this tree: field_0x3bc; the keep's entry as playerDataArray[1].buildingEntryInfos[BEIE_KEEP]
   (yEntry 0x0115F888 and xEntry 0x0115F884 are read in that order, hence the two locals); state_2's 6 as
   US_FIRE_WEAPONUnk (changeUnitType, 0x0053E6C0, copies state_2 into the new engine's state).
3. The `frame >= 4` test after `& 3` is never true, but the original compares and stores it (0x005307D1), so it
   stays, with a fixme comment; `(fixedRng + 1) & 3` in parentheses, `animationCycleNumber++`, const locals.

Measured with real builds of the units stack's head 6e3de74062 (the headers this file includes are the same there
as on main 0e4a83b; its one callee, calculatePreferredRelativeOrientation, is reimplemented in neither), the
whole build list plus this file and its /GL line, BUILD_OK each: UpdateSiegeTent 100.0 raw / 100.0 normalised,
no diff entry, 345 functions; none of the other 344 reads differently. The text before the review's text
fixes (the two enum names, the comments, const locals) read the same.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kotijekriv and others added 2 commits November 24, 2026 08:21
The only conflict was the end of cmake/compiler-flags-gl.txt, where both sides added lines; both are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The only conflict was the end of cmake/compiler-flags-gl.txt, where both sides added lines; both are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gynt
gynt previously approved these changes Nov 24, 2026
@gynt
gynt added this pull request to the merge queue Nov 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 24, 2026
@gynt
gynt merged commit f65996e into sourcehold:main Nov 24, 2026
3 checks passed
gynt pushed a commit to kotijekriv/OpenSHC that referenced this pull request Nov 24, 2026
…old#416, sourcehold#433 and sourcehold#438 (sourcehold#491)

sourcehold#416, sourcehold#433 and sourcehold#438 put six callers on cmake/compiler-flags-gl.txt after sourcehold#398 without an entry here: InGameMenu's
MenuItemRenderFunction_InGameMenu_MainButtons and Roundtable's MenuItemActionHandler_Roundtable_Main (sourcehold#416),
UpdateGhost (sourcehold#416), UpdateFireWatch and UpdateHunterDog (sourcehold#433), and UpdateCageDog (sourcehold#438). Each gets an entry at its
address, its callees in address order. The /GL lines stay as they are.

Each edge is measured as sourcehold#398's were: the caller's file compiled with the callee files in its unit, against the
caller alone, quick_diff on main 7c2e4d6 with every function resolver that has a .cpp and every struct resolver
on. The callees tried are the caller's /GL-listed callees below its address. A callee is listed when it raises the
caller's ratio on its own, or when leaving it out of the full set lowers it; the listed set reads what the full set
reads.

- MainButtons: 0.8217 alone, 1.0000 with ButtonGmData::getPictureNumberInGm.
- Roundtable_Main: 0.9391 alone, 0.9984 with GameSynchronyState::isAIPlayer.
- UpdateFireWatch: 0.3834 alone, 0.9980 with checkIfCitizenUnitIsAliveBasedOnState and hasUnitReachedDestination,
  the same as with all four of its /GL callees; leaving one of the four out reads 0.7178
  (checkIfCitizenUnitIsAliveBasedOnState) and 0.6606 (hasUnitReachedDestination).
  makeUnitStopWalkingByClearingPathProgressState and commitUnitLocation change nothing.
- UpdateGhost: 0.5214 alone, 0.9712 with hasUnitReachedDestination. makeUnitStopWalkingByClearingPathProgressState
  changes nothing.
- UpdateHunterDog: 0.3336 alone, 1.0000 with its four callees and with all five of its /GL callees; leaving one of
  the five out reads 0.9944 (makeUnitStopWalkingByClearingPathProgressState), 0.7283
  (checkIfCitizenUnitIsAliveBasedOnState), 0.9298 (hasUnitReachedDestination), 0.9114
  (hasTunnelerNotFinishedDigging). resumeMovementIfNoAttackTarget changes nothing.
- UpdateCageDog: 0.2829 alone, 1.0000 with its four callees and with all seven of its /GL callees; leaving one of
  the seven out reads 0.8651 (makeUnitStopWalkingByClearingPathProgressState), 0.7162
  (checkIfCitizenUnitIsAliveBasedOnState), 0.4142 (hasUnitReachedDestination), 0.9949 (tryAttackUnitID, which sourcehold#438
  added to the /GL list for it). buildingIsAccessible, resumeMovementIfNoAttackTarget and commitUnitLocation change
  nothing.

sourcehold#473 and sourcehold#475 put UpdateSiegeTent and UpdateHorseArcher_DoShooting on the /GL list; neither calls a /GL-listed
function, so neither gets an entry. UpdateHorseArcher calls UpdateHorseArcher_DoShooting, which sits below it, but
reads worse with its body (0.9929 with hasUnitReachedDestination, 0.9906 with both), so its entry stays as it is.

With every .cpp of main as the build list, cmake/function-visibility-units.py now makes 24 units holding 116 source
files (108 before): the six callers, tryAttackUnitID and makeUnitStopWalkingByClearingPathProgressState join the
existing groups. No internal names clash, and the 13 names it skips are the ones it skipped before.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants